package cn.edu.scau.cmi.zhangjunjia.composite.consistent;

import javafx.fxml.FXML;

import javafx.scene.control.Button;

import javafx.scene.control.TextField;

import javafx.event.ActionEvent;

import javafx.scene.control.TextArea;

public class Controller {
	@FXML
	private TextField member1;
	@FXML
	private TextField member2;
	@FXML
	private TextField team;
	@FXML
	private TextField teamMember1;
	@FXML
	private TextField teamMember2;
	@FXML
	private TextField member3;
	@FXML
	private TextArea orgMsg;
	@FXML
	private TextArea OrgMsg2;
	@FXML
	private Button commit;

	// Event Listener on Button[#commit].onAction
	@FXML
	public void commitBtn(ActionEvent event) {
		// TODO Autogenerated
		ConsistentTeam root = new ConsistentTeam("Organization");
		ConsistentPerson consitentPersonA = new ConsistentPerson(member1.getText());
		root.add(consitentPersonA);
		
		ConsistentPerson consitentPersonB = new ConsistentPerson(member2.getText());
		root.add(consitentPersonB);
		
		ConsistentTeam branch = new ConsistentTeam(team.getText());
		
		ConsistentPerson teamMemberA = new ConsistentPerson(teamMember1.getText());
		branch.add(teamMemberA);
		
		ConsistentPerson teamMemberB = new ConsistentPerson(teamMember2.getText());
		branch.add(teamMemberB);
		
		root.add(branch);
		
		ConsistentPerson consitentPersonC = new ConsistentPerson(member3.getText());
		root.add(consitentPersonC);
		
		orgMsg.setText(root.output(1));
		
		root.remove(consitentPersonC);
		OrgMsg2.setText(root.output(1));
	}
}
